using ASP;
using HoWave.Common;
using HoWave.Web;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
namespace tenpay
{
	public class return_url : Page, IRequiresSessionState
	{
		protected HtmlForm Form1;
		protected static DataRow Payconfig = new Config().config;
		protected DefaultProfile Profile
		{
			get
			{
				return (DefaultProfile)this.Context.Profile;
			}
		}
		protected global_asax ApplicationInstance
		{
			get
			{
				return (global_asax)this.Context.ApplicationInstance;
			}
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			string orderFormNum = base.Request.QueryString["sp_billno"];
			Conn conn = new Conn();
			Shop_Order shop_Order = new Shop_Order(conn);
			DataTable tenPayByOrderFormNum = shop_Order.GetTenPayByOrderFormNum(orderFormNum);
			string text = tenPayByOrderFormNum.Rows[0]["OrderFormNum"].ToString();
			string key = tenPayByOrderFormNum.Rows[0]["BussinesMD5Key"].ToString();
			PayResponseHandler payResponseHandler = new PayResponseHandler(this.Context);
			payResponseHandler.setKey(key);
			if (payResponseHandler.isTenpaySign())
			{
				string parameter = payResponseHandler.getParameter("sp_billno");
				string parameter2 = payResponseHandler.getParameter("total_fee");
				string parameter3 = payResponseHandler.getParameter("pay_result");
				if ("0".Equals(parameter3))
				{
					OrderAction orderAction = new OrderAction(conn);
					orderAction.PayReturn(text, "Pay");
					string str = return_url.Payconfig["SiteUrl"].ToString().Contains("http://") ? return_url.Payconfig["SiteUrl"].ToString() : ("http://" + return_url.Payconfig["SiteUrl"].ToString());
					payResponseHandler.doShow(str + "Member/Shop_BuyOrder.aspx?OrderFormNum=" + text);
				}
				else
				{
					base.Response.Write("支付失败");
				}
			}
			else
			{
				base.Response.Write("认证签名失败");
			}
		}
		protected override void OnInit(EventArgs e)
		{
			this.InitializeComponent();
			base.OnInit(e);
		}
		private void InitializeComponent()
		{
		}
	}
}
